﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using XNAFight.Engine;
using XNAFight.Characters.Core;
using XNAFight.Scene.Core;


namespace XNAFight.Scene.ToolAnime
{
    class ToolAnimeDebugOne : Screen
    {

        #region CHAMPS

        private Vector2 left_text_pos;
        private string left_text;
        private Character perso;

        private string animes_precedentes, animes_suivantes;
        private int nb_animes_prec, nb_animes_suiv;

        private AnimationData anime_en_cours;
        private float pas;

        #endregion

        public ToolAnimeDebugOne(Character _perso, AnimationData _anime_en_cours, float _pas)
            : base()
        {
            left_text = "";
            animes_precedentes = "";
            animes_suivantes = "";
            nb_animes_prec = 0;
            nb_animes_suiv = 0;
            left_text_pos = new Vector2(5, 0);
            perso = _perso;

            pas = _pas;
            anime_en_cours = _anime_en_cours;
        }

        protected override void LoadContent()
        {
            base.LoadContent();

        }

        public override void Update(GameTime _game_time)
        {
            base.Update(_game_time);

            bool animeEnCours_Trouvee = false;

            nb_animes_prec = 0;
            nb_animes_suiv = 0;
            animes_precedentes = "";
            animes_suivantes = "";

            foreach (AnimationData _anime in perso.AnimationList)
            {

                if (_anime.NomAnimation == perso.AnimationEnCours)
                {
                    animeEnCours_Trouvee = true;
                }
                else
                {
                    if (animeEnCours_Trouvee)
                    {
                        nb_animes_suiv++;
                        animes_suivantes += _anime.NomAnimation + ", ";
                    }
                    else
                    {
                        nb_animes_prec++;
                        animes_precedentes += _anime.NomAnimation + ", ";
                    }
                }

                

            }
            
            left_text = "Animation : " + perso.AnimationEnCours + " - nb animes : " + (1+nb_animes_prec+nb_animes_suiv).ToString("000") + "\n";
            left_text += "Animes precedentes : " + animes_precedentes + "\n" + "Animes suivantes : " + animes_suivantes + "\n";
            left_text += "vitesse : " + anime_en_cours.FrameParSec.ToString() + " (pas :" + pas.ToString() + ")\n";
            

            
            
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            CommonContent.SpriteBatch.Begin();

            CommonContent.SpriteBatch.DrawString(CommonContent.SmallFont, left_text, left_text_pos, Color.Black);

            CommonContent.SpriteBatch.End();
        }
                
        public override void Reset()
        {
        }

        public override void HandleInputs()
        {

        }

        public float Pas
        {
            get { return pas; }
            set { pas = value; }
        }

    }
}
